import { ref } from "vue"

export default {
  name: "Num",
  props: ["title"],
  emits: ["changeTotal"],
  setup(props, ctx) {
    let num = ref(0)
    const add = () => {
      num.value++
      ctx.emit("changeTotal", num.value)
    }

    return { num, add }
  },
  template: `
    <div>标题：{{title}}</div>
    <div>
    <button @click="add">
      You clicked me {{ num }} times.
    </button>
    </div>
    <div>总金额占比:<slot />%</div>
    `,
  // 或者 `template: '#my-template-element'`
}
